package com.juyu.miliao.common.msg;

import java.util.HashMap;
import java.util.Map;
import org.springframework.http.HttpStatus;
import com.fasterxml.jackson.annotation.JsonIgnore;

public class ErrorMsg {
	private HttpStatus status;
	private String error;
	private String msg;
	
	public ErrorMsg(HttpStatus status, String error, String msg){
		this.status = status;
		this.error = error;
		this.msg = msg;
	}

	public ErrorMsg(HttpStatus status){
		this.status = status;
	}

	
	public ErrorMsg(ErrorMsg source, String msg){
		this(source.getStatus(), source.getError(), msg);
	}
	
	@JsonIgnore
	public HttpStatus getStatus() {
		return status;
	}

	public String getError() {
		return error;
	}

	public String getMsg() {
		return msg;
	}

	public Map<String, Object> toMap(){
		Map<String, Object> map = new HashMap<>();
		if(msg != null){
			map.put("error", error);
			map.put("msg", msg);
		}
		return map;
	}
	
}
